package com.ecjtu.stadiumre_servations.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ecjtu.stadiumre_servations.entity.domain.Booking;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import java.util.List;
@Mapper
public interface BookingMapper extends BaseMapper<Booking> {

    /**
     * 查询用户最近的预约记录
     */
    List<Booking> findRecentBookingsByStudentId(@Param("studentId") String studentId,
                                                @Param("limit") int limit);

    /**
     * 统计用户预约次数
     */
    long countBookingsByStudentId(@Param("studentId") String studentId);

    /**
     * 计算用户总消费金额
     */
    double calculateTotalSpendingByStudentId(@Param("studentId") String studentId);

    /**
     * 查询用户在指定时间范围内的预约
     */
    List<Booking> findBookingsByStudentIdAndTimeRange(@Param("studentId") String studentId,
                                                      @Param("startTime") LocalDateTime startTime,
                                                      @Param("endTime") LocalDateTime endTime);
}